package com.etime.shycourse.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.etime.shycourse.pojo.Couponactivity;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 *
 * @author wb
 * @since 2022-03-15
 */
@Repository
public interface CouponactivityMapper extends BaseMapper<Couponactivity> {

    /**
     * 根据用户id查询该用户可以参加，但是还没有领取优惠券的活动
     *
     * @param userid 用户id
     * @return
     */
    @Select("SELECT " +
            "a.cactivityid,a.activetypeid,a.activetitle,a.activedesc,a.activebegin," +
            "a.activeend,a.activestate,a.activeallowdforward,a.activeallowedre " +
            "FROM couponactivity a " +
            "inner join activelog b on a.cactivityid=b.cactivityid " +
            "where b.activetouserid=#{userid} and b.activesharestate=1 and a.activestate=2 " +
            "and a.activeend>=curdate()")
    List<Couponactivity> selectActiveListByUserId(@Param("userid") Integer userid);

}
